package cn.laike.modules.dev.controller;

import java.util.Arrays;
import java.util.Map;

import cn.laike.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.laike.modules.dev.entity.MobileMessageRecorderEntity;
import cn.laike.modules.dev.service.MobileMessageRecorderService;
import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.R;



/**
 * 短信验证记录
 *
 * @author ziye
 * @email 524748907@qq.com
 * @date 2019-02-20 15:09:14
 */
@RestController
@RequestMapping("dev/mobilemessagerecorder")
public class MobileMessageRecorderController {
    @Autowired
    private MobileMessageRecorderService mobileMessageRecorderService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("dev:mobilemessagerecorder:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mobileMessageRecorderService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("dev:mobilemessagerecorder:info")
    public R info(@PathVariable("id") Integer id){
        MobileMessageRecorderEntity mobileMessageRecorder = mobileMessageRecorderService.selectById(id);

        return R.ok().put("mobileMessageRecorder", mobileMessageRecorder);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("dev:mobilemessagerecorder:save")
    public R save(@RequestBody MobileMessageRecorderEntity mobileMessageRecorder){
        mobileMessageRecorderService.insert(mobileMessageRecorder);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("dev:mobilemessagerecorder:update")
    public R update(@RequestBody MobileMessageRecorderEntity mobileMessageRecorder){
        ValidatorUtils.validateEntity(mobileMessageRecorder);
        mobileMessageRecorderService.updateAllColumnById(mobileMessageRecorder);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("dev:mobilemessagerecorder:delete")
    public R delete(@RequestBody Integer[] ids){
        mobileMessageRecorderService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
